
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_Hans">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>部署 Django &#8212; Django 3.2.11.dev 文档</title>
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <link rel="index" title="索引" href="../../genindex.html" />
    <link rel="search" title="搜索" href="../../search.html" />
    <link rel="next" title="如何使用 WSGI 进行部署" href="wsgi/index.html" />
    <link rel="prev" title="编写一个自定义存储系统" href="../custom-file-storage.html" />



 
<script src="../../templatebuiltins.js"></script>
<script>
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../index.html">Django 3.2.11.dev 文档</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../index.html">Home</a>  |
        <a title="Table of contents" href="../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../genindex.html">Index</a>  |
        <a title="Module index" href="../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="../custom-file-storage.html" title="编写一个自定义存储系统">previous</a>
     |
    <a href="../index.html" title="操作指南" accesskey="U">up</a>
   |
    <a href="wsgi/index.html" title="如何使用 WSGI 进行部署">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="howto-deployment-index">
            
  <div class="section" id="s-deploying-django">
<span id="deploying-django"></span><h1>部署 Django<a class="headerlink" href="#deploying-django" title="永久链接至标题">¶</a></h1>
<p>Django 中简化 Web 开发的快捷函数俯拾皆是，但是如果不能轻松部署网站的话，所有的工具都徒劳无益。Django 从最初就把方便部署当作一个主要目标。</p>
<p>部署你的Django应用程序有很多选择，可以基于你的架构或者特定的业务需要，但是这不在Django可以给出指导建议的范围内。</p>
<p>Django是一个需要Web服务器来运行的Web框架。然而由于大多数Web服务器不是用Python编写，我们需要一个接口来实现沟通。</p>
<p>Django现在支持两种接口：WSGI和ASGI。</p>
<ul class="simple">
<li><a class="reference external" href="https://wsgi.readthedocs.io/en/latest/">WSGI</a> 是主要的用于应用程序和Web服务器通信的Python标准，但是它只支持同步代码。</li>
<li><a class="reference external" href="https://asgi.readthedocs.io/en/latest/">ASGI</a> 是新兴的，对异步友好的让你的Django网页使用Python异步特性和已经开发的Django异步特性的标准。</li>
</ul>
<p>你必须要考虑如何处理你的应用程序的静态文件  :doc:` static files 1` ，以及如何处理  <span class="xref std std-doc">error reporting2</span>。</p>
<p>最后，在将你的应用程序部署到生产环境中之前，你应该执行一遍 <span class="xref std std-doc">deployment checklist 1</span> 以确保你的配置是合适的。</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="wsgi/index.html">如何使用 WSGI 进行部署</a><ul>
<li class="toctree-l2"><a class="reference internal" href="wsgi/gunicorn.html">如何使用 Gunicorn 托管 Django</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi/uwsgi.html">如何用 uWSGI 托管 Django</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi/modwsgi.html">如何使用 Apache 和 <code class="docutils literal notranslate"><span class="pre">mod_wsgi</span></code> 托管 Django</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi/apache-auth.html">Apache 利用 Django 的用户数据库进行验证</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi/index.html#the-application-object"><code class="docutils literal notranslate"><span class="pre">application</span></code> 对象</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi/index.html#configuring-the-settings-module">配置 settings 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi/index.html#applying-wsgi-middleware">应用 WSGI 中间件</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="asgi/index.html">如何使用 ASGI 来部署</a><ul>
<li class="toctree-l2"><a class="reference internal" href="asgi/daphne.html">如何使用 Daphne 托管 Django</a></li>
<li class="toctree-l2"><a class="reference internal" href="asgi/hypercorn.html">如何使用 Hypercorn 托管 Django。</a></li>
<li class="toctree-l2"><a class="reference internal" href="asgi/uvicorn.html">如何使用 Uvicorn 托管 Django</a></li>
<li class="toctree-l2"><a class="reference internal" href="asgi/index.html#the-application-object"><code class="docutils literal notranslate"><span class="pre">application</span></code> 对象</a></li>
<li class="toctree-l2"><a class="reference internal" href="asgi/index.html#configuring-the-settings-module">配置 settings 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="asgi/index.html#applying-asgi-middleware">应用 ASGI 中间件</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="checklist.html">部署清单</a><ul>
<li class="toctree-l2"><a class="reference internal" href="checklist.html#run-manage-py-check-deploy">运行 <code class="docutils literal notranslate"><span class="pre">manage.py</span> <span class="pre">check</span> <span class="pre">--deploy</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="checklist.html#critical-settings">关键配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="checklist.html#environment-specific-settings">特定于环境的配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="checklist.html#https">HTTPS</a></li>
<li class="toctree-l2"><a class="reference internal" href="checklist.html#performance-optimizations">性能优化</a></li>
<li class="toctree-l2"><a class="reference internal" href="checklist.html#error-reporting">发送错误</a></li>
</ul>
</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>上一个主题</h4>
  <p class="topless"><a href="../custom-file-storage.html"
                        title="上一章">编写一个自定义存储系统</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="wsgi/index.html"
                        title="下一章">如何使用 WSGI 进行部署</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/howto/deployment/index.txt"
            rel="nofollow">显示源代码</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>快速搜索</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="转向" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">12月 07, 2021</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="../custom-file-storage.html" title="编写一个自定义存储系统">previous</a>
     |
    <a href="../index.html" title="操作指南" accesskey="U">up</a>
   |
    <a href="wsgi/index.html" title="如何使用 WSGI 进行部署">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>